unit ButtonEdit;
interface

uses 
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls, Buttons;

type
TddgButtonEdit = class(TWinControl)
private
FSpeedButton: TSpeedButton;
FEdit: TEdit;

protected
procedure WMSize(var Message: TWMSize); 
                                                       message WM_SIZE;
function GetText: String;
procedure SetText(Value: String);

function GetFont: TFont;
procedure SetFont(Value: TFont);

function GetOnButtonClick: TNotifyEvent;
procedure SetOnButtonClick(Value: TNotifyEvent);

public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;

    published
property Text: String 
          read GetText write SetText;
property Font: TFont 
          read GetFont write SetFont;
property OnButtonClick: TNotifyEvent 
          read GetOnButtonClick write SetOnButtonClick;
end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TddgButtonEdit]);
end;

procedure TddgButtonEdit.WMSize(var Message: TWMSize);
begin
inherited;
FEdit.Width := Message.Width-FSpeedButton.Width;
FSpeedButton.Left := FEdit.Width;
end;

constructor TddgButtonEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

FEdit := TEdit.Create(Self);
FEdit.Parent := self;
FEdit.Height := 21;

FSpeedButton := TSpeedButton.Create(Self);
FSpeedButton.Left := FEdit.Width;
FSpeedButton.Height := 19; 
FSpeedButton.Width := 19;
FSpeedButton.Caption := '...';
FSpeedButton.Parent := Self;

Width := FEdit.Width+FSpeedButton.Width;
Height := FEdit.Height;
end;

destructor TddgButtonEdit.Destroy;
begin
FSpeedButton.Free;
FEdit.Free;
inherited Destroy;
end;

function TddgButtonEdit.GetText: String;
begin
	Result := FEdit.Text;
end;

procedure TddgButtonEdit.SetText(Value: String);
begin
	FEdit.Text := Value;
end;

function TddgButtonEdit.GetFont: TFont;
begin
	Result := FEdit.Font;
end;

procedure TddgButtonEdit.SetFont(Value: TFont);
begin
	if Assigned(FEdit.Font) then
			FEdit.Font.Assign(Value);
end;

function TddgButtonEdit.GetOnButtonClick:
																 TNotifyEvent;
begin
	Result := FSpeedButton.OnClick;
end;

procedure TddgButtonEdit.SetOnButtonClick(
                                                   Value: TNotifyEvent);
begin
	FSpeedButton.OnClick := Value;
end;

end.
